<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/common.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<meta charset="utf-8">
<head></head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-taxDeclaration-add">
			<input type="hidden" id="txId" name="txId" value="${txId}" />
			<div class="form-group">
				<label class="col-sm-3 control-label">纳税人：</label>
				<div class="col-sm-8">
					<input id="owner" name="owner" value="${owner}" class="form-control" type="text" readonly="readonly">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">所属公司：</label>
				<div class="col-sm-8">
					<input id="company" name="company" value="${company}" class="form-control" type="text" readonly="readonly">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">税种：</label>
				<div class="col-sm-8">
					<select id="declarationTaxType" name="declarationTaxType" class="form-control">

					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">税目：</label>
				<div class="col-sm-8">
					<select id="declarationTaxModel" name="declarationTaxModel" class="form-control">

					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">计税依据：</label>
				<div class="col-sm-8">
					<input id="declarationTaxBasis" name="declarationTaxBasis" class="form-control" type="text" readonly="readonly">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">应纳税项目：</label>
				<div class="col-sm-8">
					<input id="declarationTaxProject" name="declarationTaxProject" class="form-control" type="text">
				</div>
			</div>


			<div class="form-group">
				<label class="col-sm-3 control-label">扣除项目及标准：</label>
				<div class="col-sm-8">
					<select id="declarationTaxCondition" name="declarationTaxCondition" class="form-control" onchange="doChange()">

					</select>


				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">适用税率（%）：</label>
				<div class="col-sm-8">
					<input id="declarationTaxRate" name="declarationTaxRate" class="form-control" type="text" readonly="readonly">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">应纳税额：</label>
				<div class="col-sm-8">
					<input id="declarationTaxMoney" name="declarationTaxMoney" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">代收代缴税额：</label>
				<div class="col-sm-8">
					<input id="declarationReplaceMoney" name="declarationReplaceMoney" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">税款所属期限：</label>
				<div class="col-sm-8">
					<input id="declarationTaxTime" name="declarationTaxTime" class="form-control" type="text" readonly="readonly">
				</div>
			</div>
		</form>
	</div>
	<script src="${ctx}/static/js/tax.json"></script>
	<script type="text/javascript">
		var prefix = "${ctx}/system/declaration"
		$("#form-taxDeclaration-add").validate({
			rules : {
				declarationTaxType : {
					required : true,
				},
				declarationTaxProject : {
					required : false,
				},
				declarationTaxModel : {
					required : true,
				},
				declarationTaxTime : {
					required : true,
				},
				declarationReplaceMoney : {
					required : true,
					range : [ 1, 100000000000 ]
				},
				declarationTaxMoney : {
					required : true,
					range : [ 1, 100000000000 ]
				},
			}
		});
	
		function submitHandler() {
			if ($.validate.form()) {
				$.operate.save(prefix + "/add", $('#form-taxDeclaration-add').serialize());
				window.parent.go();
			}
		}
	
	
		//获得省级下拉框对象
		var province = $("#declarationTaxType");
		var option = "<option value=''>--请选择--</option>";
		//遍历省市数据,并把里面省的数据追加到option选项中
		for (var i = 0; i < china.length; i++) {
			option += "<option value='" + china[i].p_id + "'  ";
			if ('${cartype.cartypeBrand}' == china[i].p_id) {
				option += " selected ";
			}
			option += ">" + china[i].p_name + "</option>";
		}
		province.append(option);
		/* if ('${cartype.cartypeBrand}' != "") {
			changeCar('${cartype.cartypeBrand}');
		} */
	
	
		//省级下拉框发生改变事件
		$("#declarationTaxType").change(function() {
			//获取当前点击对象的值
			var proid = $(this).val();
			changeCar(proid);
			changeCondition(proid);
			var str = "";
			if (proid == "个人所得税") {
				$("#declarationTaxBasis").val("纳税人取得的应纳税所得额");
			} else if (proid == "企业所得税") {
				$("#declarationTaxBasis").val("按应纳税所得额（纳税调整后的利润）");
			}
		});
	
	
		function changeCondition(proid) {
			var content;
			//遍历省市数据,把省级下点击的那一个选项的值和省市数据中的
			//省级数据对比,如果相等,取出当前的市的数据
			for (var i = 0; i < china.length; i++) {
				if (proid == china[i].p_id) {
					content = china[i].content;
				}
			}
			//获得市级下拉框对象
			var city = $("#declarationTaxCondition");
			//每次点击省级后,市级初始化,避免高级重复追加 
			var option = "<option value=''>--请选择--</option>";
			//遍历市级数据,并取出市级数据,追加到市级对象中
			for (var i = 0; i < content.length; i++) {
				option += "<option value='" + content[i].c_id + "'  ";
				/* if ('${cartype.cartypeName}' == content[i].c_id) {
					option += " selected ";
				} */
				option += " num='" + content[i].c_num + "'";
				option += ">" + content[i].c_name + "</option>";
			}
			city.html(option);
		}
	
	
		function changeCar(proid) {
			var cities;
			//遍历省市数据,把省级下点击的那一个选项的值和省市数据中的
			//省级数据对比,如果相等,取出当前的市的数据
			for (var i = 0; i < china.length; i++) {
				if (proid == china[i].p_id) {
					cities = china[i].cities;
				}
			}
			//获得市级下拉框对象
			var city = $("#declarationTaxModel");
			//每次点击省级后,市级初始化,避免高级重复追加 
			var option = "<option value=''>--请选择--</option>";
			//遍历市级数据,并取出市级数据,追加到市级对象中
			for (var i = 0; i < cities.length; i++) {
				option += "<option value='" + cities[i].c_id + "'  ";
				if ('${cartype.cartypeName}' == cities[i].c_id) {
					option += " selected ";
				}
				option += ">" + cities[i].c_name + "</option>";
			}
			city.html(option);
		}
	
		zaneDate({
			elem : '#declarationTaxTime',
			format : 'yyyy-MM-dd',
			min : '2000-08-20',
			max : '2027-08-20',
		});
	
		function doChange() {
			var num = jQuery("#declarationTaxCondition  option:selected").attr("num");
			$("#declarationTaxRate").val(num);
	
		}
	</script>
</body>
</html>
